package com.yunhe.controller;

import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.yunhe.model.Admin;
import com.yunhe.model.UserModel;
import com.yunhe.service.IAdminService;

public class AdminAction extends ActionSupport implements ModelDriven<Object> {

	
	private static final long serialVersionUID = 1L;
	
	@Autowired
	private IAdminService adminService;
	private Admin admin;
	private String username;
	private String password;
	

	public IAdminService getAdminService() {
		return adminService;
	}


	public void setAdminService(IAdminService adminService) {
		this.adminService = adminService;
	}


	public Admin getAdmin() {
		return admin;
	}


	public void setAdmin(Admin admin) {
		this.admin = admin;
	}


	public static long getSerialversionuid() {
		return serialVersionUID;
	}


	public String getUsername() {
		return username;
	}


	public void setUsername(String username) {
		this.username = username;
	}


	public String getPassword() {
		return password;
	}


	public void setPassword(String password) {
		this.password = password;
	}
    /**
     * 查询管理员信息
     */
	public String findAdmin(){
		admin=adminService.findAdmin(admin);
        if(admin!=null){
		ServletActionContext.getRequest().setAttribute("adminSession",admin);

		return "success";
		}else{
			return "error";
		}
		
	}
	@Override
	public Object getModel() {
		if(admin==null){
	    	 admin = new Admin(); 
	      }
			return admin;
	}

}
